package com.schoolpro.constant;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;


public enum PropertyNameEnum {
    PROPERTYNAME("propertyName"),
    CATEGORYNAME("categoryName"),
    REQUIRED("required"),
    ENUMERABLE("enumerable"),
    MAXLENGTH("maxLength"),
    DATATYPE("dataType"),
    DEFAULTVALUE("defaultValue"),
    ;

    private final String value;

    PropertyNameEnum(String value) {
        this.value = value;
    }

    @JsonValue  // 序列化时使用 value 字段
    public String getValue() {
        return value;
    }

    @JsonCreator  // 反序列化时根据 value 匹配枚举
    public static PropertyNameEnum fromValue(String value) {
        for (PropertyNameEnum enumItem : PropertyNameEnum.values()) {
            if (enumItem.value.equalsIgnoreCase(value)) {
                return enumItem;
            }
        }
        throw new IllegalArgumentException("无效的属性名: " + value);
    }
}